-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Main Page #3
Main Page #3
Conversation
src/components/CountryPage/index.tsx
Outdated
// TODO | ||
|
||
return (<div title={t(`${countryId}.name`)}>{t(`${countryId}.name`)}</div>); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Файлы компонентов лучше называть по имени компонента вместо index.tsx
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Не согласна: именование index.tsx позволяет уменьшить длину строки импорта модуля, так как index - это "специальное" имя, которое ищется внутри папки по умолчанию.
Благодаря index мы можем написать путь './component/App' вместо './components/App/App'
src/components/CountryPage/index.tsx
Outdated
} from 'react-router-dom'; | ||
|
||
|
||
export default function CountryPage(): JSX.Element { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
почему тип компонента JSX.Element? не лучше в одном стиле, также как и все остальные компоненты, React.FC?
Еще у меня как-то некорректно работает роутинг. |
Это неизбежно. Можно убрать рут countries и делать это корнем |
Тогда я за то чтобы убрать. |
@@ -1,9 +1,56 @@ | |||
export interface IAppState { | |||
lang: 'EN' | 'RU' | 'DE' | |||
lang: 'EN' | 'RU' | 'DE', | |||
countries: Country[], | |||
} | |||
|
|||
const initialState: IAppState = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Это initial state не всего App, а только для Main page, его лучше вынести в отдельный файл, например, mainPageReduser, и импортировать его в rootReduser
src/store/rootReducer.ts
Outdated
name: 'Japan', | ||
pictureURL: 'https://i-fakt.ru/1/tokio.jpg', | ||
}, | ||
], | ||
}; | ||
|
||
const rootReducer = (state: IAppState = initialState, action: any) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const rootReducer = (state: IAppState = initialState, action: any)
action type должен быть описан соответствующим интерфейсом, например,
interface IRoorReduserAction {
type: string;
lang?: string;
countries?: Array
}
src/components/ImagesGrid/index.tsx
Outdated
); | ||
const ImagesGrid: React.FC<rootProps> = (props: rootProps) => { | ||
const classes = useStyles(); | ||
const { lang, countries } = props; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
если lang не используется, может быть его записать спред-оператором ... . + такой записи еще и втом, что не при раширении rootProps, на придется дописывать новые свойства
Main application page with counties list. Contains routing and i18next internationalization